home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 17 / CU Amiga Magazine's Super CD-ROM 17 (1997)(EMAP Images)(GB)[!][issue 1997-12].iso / CUCD / Programming / DiceSource / src / editors / AME / Rexx / vmodes.ame < prev    next >
Encoding:
Text File  |  1994-02-01  |  3.2 KB  |  151 lines

  1. /* $VER: VModes 37.1 (21.2.93) */
  2. /* This program brings up a Buffer Modes Requester for AME */
  3.  
  4. if show("l", "rexxarplib.library") = 0 then do
  5.    check = addlib('rexxsupport.library', 0, -30, 0)
  6.    check = addlib('rexxarplib.library',  0, -30, 0)
  7. end
  8.  
  9. options results
  10.  
  11. /*
  12. *   The following sequence determines both AME's screen and port name,
  13. *   and also gets the number screen rows and columns.
  14. */
  15.  
  16. ameport = address()
  17. cols = ScreenCols(ameport)
  18. if cols == -1 then do
  19.    amescreen = ""
  20.    cols = ScreenCols()
  21.    rows = ScreenRows()
  22. end
  23. else do
  24.    amescreen = ameport
  25.    rows = ScreenRows(amescreen)
  26. end
  27. /*
  28.  *   Set up a host. This time, send all messages to our own port.
  29.  */
  30.  
  31. address AREXX "'x = CreateHost(AMEPREFS, PREFSPORT, "amescreen")'"
  32. /*
  33.  *   Wait until it is ready.
  34.  */
  35. do i = 1
  36.    if showlist('p', AMEPREFS) ~= 0 then leave
  37.    call delay 30
  38. end
  39.  
  40. /*
  41.  *   Open the window
  42.  */
  43.  
  44. idcmp = 'CLOSEWINDOW+GADGETUP'
  45. flags = 'WINDOWCLOSE+WINDOWDRAG+WINDOWDEPTH+ACTIVATE'
  46.  
  47. call OpenWindow(AMESEARCH, (cols - 640)/2, rows - 190, 480, 100, idcmp,   ,
  48.                 flags, "Set Buffer Modes...")
  49.  
  50. /*
  51.  *   Open the port that messages will come to
  52.  */
  53. mp = openport(PREFSPORT)
  54.  
  55.  
  56. /*   Read the current settings */
  57. template = "CMODE EXT MBYTE OVER READ TEMP WRAP"
  58. parse var template v.1 v.2 v.3 v.4 v.5 v.6 v.7
  59. 'getprefs' template
  60. parse var result p.1 p.2 p.3 p.4 p.5 p.6 p.7 .
  61.  
  62.  
  63. /*
  64.  *   Add the gadgets
  65.  */
  66.  
  67. call AddGadget(AMEPREFS, 50,  18, 1, "  ", "%d")
  68. call AddGadget(AMEPREFS, 50,  36, 2, "  ", "%d")
  69. call AddGadget(AMEPREFS, 50,  54, 3, "  ", "%d")
  70.  
  71. call AddGadget(AMEPREFS, 200,  18, 4, "  ", "%d")
  72. call AddGadget(AMEPREFS, 200,  36, 5, "  ", "%d")
  73.  
  74. call AddGadget(AMEPREFS, 350,  18, 6, "  ", "%d")
  75. call AddGadget(AMEPREFS, 350,  36, 7, "  ", "%d")
  76.  
  77.  
  78. Call Move(AMEPREFS,80,24)
  79. Call Text(AMEPREFS,"CMODE")
  80. Call Move(AMEPREFS,80,42)
  81. Call Text(AMEPREFS,"External")
  82. Call Move(AMEPREFS,80,60)
  83. Call Text(AMEPREFS,"Multibyte")
  84.  
  85. Call Move(AMEPREFS,230,24)
  86. Call Text(AMEPREFS,"Overwrite")
  87. Call Move(AMEPREFS,230,42)
  88. Call Text(AMEPREFS,"Read only")
  89.  
  90. Call Move(AMEPREFS,380,24)
  91. Call Text(AMEPREFS,"Temp")
  92. Call Move(AMEPREFS,380,42)
  93. Call Text(AMEPREFS,"Wrap")
  94.  
  95.  
  96. call AddGadget(AMEPREFS, 50, 80, "USE",   "  OK    ", "USE")
  97. call AddGadget(AMEPREFS,350, 80, "CLOSE", " Cancel ", "CANCEL")
  98.  
  99. /*
  100.  *   set gadgets that should be on
  101.  */
  102.  
  103. do i = 1 to 7
  104.     if(left(p.i,1,1)= 'N') then do
  105.     res = SetGadget(AMEPREFS, i, "OFF")
  106.     end
  107.     else do
  108.     res = SetGadget(AMEPREFS, i, "ON")
  109.         end
  110.     end
  111.  
  112. /*
  113.  *   Main event loop
  114.  */
  115. quitflag  = 0
  116.  
  117. do forever
  118.    if quitflag = 1 then leave
  119.    t = waitpkt(PREFSPORT)
  120.    do forever
  121.       p = getpkt(PREFSPORT)
  122.       if c2d(p) = 0 then leave
  123.       cmd = getarg(p)
  124.       t = reply(p, 0)
  125.  
  126.       /* see what we got */
  127.       if cmd = "CANCEL" then do
  128.          call CloseWindow(AMEPREFS)
  129.          quitflag = 1
  130.          end
  131.       else if cmd = "USE" | cmd = "CLOSEWINDOW" then do
  132.          call CloseWindow(AMEPREFS)
  133.      do i = 1 to 7
  134.          if left(p.i,1,1) = 'N' then 'unsetprefs' v.i
  135.          else 'setprefs' v.i
  136.          end
  137.          quitflag = 1
  138.          end
  139.       else if datatype(cmd, 'W') = 1 then do
  140.          if left(p.cmd,1,1) = 'N' then do
  141.         call SetGadget(AMEPREFS, cmd, "ON")
  142.         p.cmd = 'O'
  143.         end
  144.          else do
  145.         call SetGadget(AMEPREFS, cmd, "OFF")
  146.         p.cmd = 'N'
  147.           end
  148.       end
  149.       end
  150.     end
  151. exit